import java.io.*;
import java.net.*;

public class serveru
{
	public static void main(String arg[])throws IOException
	{
		DatagramSocket serversock =new DatagramSocket(9090);
		byte[] send;
		byte[] recieve=new byte[1024];
		BufferedReader x=new BufferedReader(new InputStreamReader(System.in));
		DatagramPacket recievepack=new DatagramPacket(recieve,recieve.length);
		serversock.receive(recievepack);
		String rec=new String(recievepack.getData(),0,recievepack.getLength());
		System.out.println(""+rec);
		String str;
		str=x.readLine();
		InetAddress ip=recievepack.getAddress();
		int port=recievepack.getPort();
		send=str.getBytes();
		DatagramPacket sendpack=new DatagramPacket(send,send.length,ip,port);
		serversock.send(sendpack);
	}
}
